package com.whitesalt.inputfix;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SettingTitle extends JDialog
{
    private JPanel contentPane;
    private JButton buttonOK;
    JTextField Title;


    SettingTitle()
    {
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        setPreferredSize(new Dimension(200, 120));
        setLocationRelativeTo(getOwner());
        setTitle("请设置一个窗口标题：");

        buttonOK.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                onOK();
            }
        });
    }

    private void onOK()
    {
        if(Title.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null, "为了便于管理，您必须设置一个命令窗口标题！", "提示",JOptionPane.INFORMATION_MESSAGE);
        }
        else
        {
            dispose();
        }
    }

}
